Experiment: optimized representation for nat constants (a zarith Z.t values)#21729
Draft
SkySkimmer wants to merge 46 commits intorocq-prover:masterfrom
Draft
Experiment: optimized representation for nat constants (a zarith Z.t values)#21729SkySkimmer wants to merge 46 commits intorocq-prover:masterfrom
nat constants (a zarith Z.t values)#21729SkySkimmer wants to merge 46 commits intorocq-prover:masterfrom
Conversation
Member
|
It's not because all your friends are jumping off a cliff that you should do it... |
2cc50b3 to
a76d28b
Compare
the main motivation is actually to be able to compare between representations in constr_equal
SkySkimmer
added a commit
to SkySkimmer/Coq-Equations
that referenced
this pull request
Mar 11, 2026
SkySkimmer
added a commit
to SkySkimmer/MetaRocq
that referenced
this pull request
Mar 11, 2026
Contributor
Author
|
@coqbot bench |
Contributor
Author
|
@coqbot bench |
Contributor
Author
|
@coqbot bench |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current state has some random TODOs and term matching (notation printing, ltac matching) is probably janky but is enough to have a look.
Prelude
natdoes not use the optimization (so CI should say nothing interesting), see new test filebignatfor actual use of the optimization.The optimization is similar to what agda https://agda.readthedocs.io/en/latest/language/built-ins.html#natural-numbers and lean https://lean-lang.org/doc/reference/latest/Basic-Types/Natural-Numbers/ have: closed nat values ("nat constants") can be represented by
Nat of Z.t.The cbv machine has optimized implementations for
+/*on nat constants (the one for tail_mul is necessary to get large literals to work).The VM produces values using the optimized representation but has no special handling for operators.
cclosure/
lazy/cclosure-based conversion can handle inputs which contain the optimized representation but do not build larger values using it, ie1 + 1where1is optimized reduces toS 1(which converts correctly to2).TBH I'm not sure how to do otherwise in a lazy/call by name setting, if we see
1 + efor some arbitrary expressionewe should not reducee(at least in weak head mode).native_compute, cbn and reductionops do
failwith "TODO"on optimized constants.I think tacred treats optimized constants as opaque values but who knows what this code even is.